package com.ssm.dao;

import com.ssm.bean.Account;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * 用户的持久层
 */
public interface IAccountDao {

    //查询所有用户
    @Select("select * from account")
    @Results(value = {
            @Result(id = true,column = "aid",property = "aid"),
            @Result(column = "uid",property = "uid"),
            @Result(column = "money",property = "money"),
            @Result(property = "user",column = "uid",one = @One(select="com.ssm.dao.IUserDao.getUserById",fetchType= FetchType.EAGER))
    })
    public List<Account> findAll();


    //通过uid查询账户
    @Select("select * from account where uid = #{uid}")
    public List<Account> getAccountByUid(Integer uid);

}
